import Vue from 'vue'
import VueRouter from 'vue-router'
//引入Footer组件
import Footer from '@/components/Footer'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/home'
  },
  {
    path: '/home',
    name: 'home',
    //正常懒加载   component: () => import('@/views/Home')
    //footer启用命名视图
    components : {
      default: () => import('@/views/Home'),
      footer:Footer
    }
  },
  {
    path: '/cart',
    name: 'cart',
    components: {
      default: () => import('@/views/Cart'),
      footer:Footer
    }
  },
  {
    path: '/kind',
    name: 'kind',
    components: {
      default: () => import('@/views/Kind'),
      footer:Footer
    }
  },
  {
    path: '/user',
    name: 'user',
    components: {
      default: () => import('@/views/User'),
      footer:Footer
    }
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/Register')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
